var e = {}, 
  url = "https://company.chengnuorunxin.com/admin/api",
  // url = "http://localhost:8080/api", 
  webSocketUrl = "wss://company.chengnuorunxin.com/ws", 
  imgURL = 'https://company.chengnuorunxin.com/cnimg/simple',
  app = getApp();

e.httpPost = function (u,d, s, f) {
  var o = u;
  o = url + o;
  console.log('user_id storage', getApp().getStorageSync('user_id'))
  var user_id = getApp().getStorageSync('user_id')
  var access_token = getApp().getStorageSync('access_token')
  if (user_id == undefined || user_id == '' || user_id == null ){
    user_id = getApp().globalData.user_id;
  }
  d["platform"] = "wxmini";
  var req_user_id = d["user_id"];
  if(!req_user_id){
    d["user_id"] =  user_id;
  }

  wx.request({
    url: o,
    data: d,
    method: 'POST',
    header: { 
      "Content-Type": "application/json;charset=UTF-8",
      "user_id":user_id,
      "access_token":access_token,
      "platform":"wxmini"
    },
    success: function (t) {
      200 == t.statusCode ? s(t) : f(t);
    },fail: function (t) { f(t); }
  });
}

e.getPlatformUrl = function(){
  return url;
}

e.getWebSokectUrl = function(){
  return webSocketUrl;
}

e.getImgUrl = function(){
  return imgURL;
}

module.exports = e;

